﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();   textBox2.ReadOnly = true;
            textBox3.ReadOnly = true;

            button1.Text = "计算";
            button2.Text = "清空";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                
                double radius = Convert.ToDouble(textBox1.Text);

               
                double area = Math.PI * radius * radius;
                double circumference = 2 * Math.PI * radius;

               
                textBox2.Text = area.ToString("F4");  
                textBox3.Text = circumference.ToString("F4");
            }
            catch (FormatException)
            {
                MessageBox.Show("请输入有效的数字作为半径！", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OverflowException)
            {
                MessageBox.Show("输入的数值过大或过小！", "数值溢出", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
           
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";

           
            textBox1.Focus();
        }
    }
}